package cn.wolfcode.edu.service.impl;

import cn.wolfcode.edu.domain.Schedule;
import cn.wolfcode.edu.mapper.ScheduleMapper;
import cn.wolfcode.edu.query.SalaryQueryObject;
import cn.wolfcode.edu.query.ScheduleQueryObject;
import cn.wolfcode.edu.service.IScheduleService;
import cn.wolfcode.edu.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by ASUS on 2018/7/10.
 */
@Service
public class ScheduleServiceImpl implements IScheduleService {
    @Autowired
    private ScheduleMapper scheduleMapper;

    @Override
    public PageResult query(ScheduleQueryObject qo) {
        int total=scheduleMapper.queryForRows(qo);
        if (total == 0) {
            return new PageResult();
        }
        List<Schedule> scheduleList = scheduleMapper.queryForList(qo);
        return new PageResult(total,scheduleList);
    }

    @Override
    public void saveSchedule(Schedule schedule) {
        scheduleMapper.insert(schedule);
    }

    @Override
    public void updateSchedule(Schedule schedule) {
        scheduleMapper.updateByPrimaryKey(schedule);
    }

    @Override
    public void deleteSchedule(Long scheduleId) {
        scheduleMapper.deleteByPrimaryKey(scheduleId);
    }

    public List queryForList(ScheduleQueryObject qo) {
        return scheduleMapper.queryForList(qo);
    }
}
